import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control // 路由守卫
import checkPermission from '@/mixin/checkPermission'
Vue.mixin(checkPermission)
// 注册指令
// 自定义指令大多都是在操作Dom
// 语法：Vue.directive(自定义指令名，配置项（{}）)
// 全部到导入 import * as 变量名 from '路径'
// (按需导出仍然可以全部导入)
import * as directives from '@/directives'

// 循环注册全部指令
Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key])
})

// 全局注册过滤器
import { formatDate } from '@/filters'
Vue.filter('formatDate', formatDate)
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */

// 删除mock相关的东西
// process是node自带的环境变量
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
import i18n from './lang'
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明

// Vue.use()  调用对象的install方法，install方法会接收一个Vue实例的参数
import PageTools from '@/components'

Vue.use(PageTools)

Vue.config.productionTip = false

// 注册打印插件
import Print from 'vue-print-nb'
Vue.use(Print)

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
